/**
 */
package UML_ER.impl;

import UML_ER.Attribute;
import UML_ER.Entity;
import UML_ER.Generalization;
import UML_ER.UML_ERPackage;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Entity</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link UML_ER.impl.EntityImpl#getGeneralization <em>Generalization</em>}</li>
 *   <li>{@link UML_ER.impl.EntityImpl#getAttribute <em>Attribute</em>}</li>
 *   <li>{@link UML_ER.impl.EntityImpl#isIsAbstract <em>Is Abstract</em>}</li>
 *   <li>{@link UML_ER.impl.EntityImpl#isIsWeak <em>Is Weak</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EntityImpl extends ElementImpl implements Entity {
	/**
	 * The cached value of the '{@link #getAttribute() <em>Attribute</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAttribute()
	 * @generated
	 * @ordered
	 */
	protected EList<Attribute> attribute;
	
	protected EList<Generalization> generalization;

	/**
	 * The default value of the '{@link #isIsAbstract() <em>Is Abstract</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isIsAbstract()
	 * @generated
	 * @ordered
	 */
	protected static final boolean IS_ABSTRACT_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isIsAbstract() <em>Is Abstract</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isIsAbstract()
	 * @generated
	 * @ordered
	 */
	protected boolean isAbstract = IS_ABSTRACT_EDEFAULT;

	/**
	 * The default value of the '{@link #isIsWeak() <em>Is Weak</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isIsWeak()
	 * @generated
	 * @ordered
	 */
	protected static final boolean IS_WEAK_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isIsWeak() <em>Is Weak</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isIsWeak()
	 * @generated
	 * @ordered
	 */
	protected boolean isWeak = IS_WEAK_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EntityImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return UML_ERPackage.Literals.ENTITY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * 
	 */
	public EList<Generalization> getGeneralization() {
		if (generalization == null) {
			generalization = new EObjectContainmentEList<Generalization>(Generalization.class, this, UML_ERPackage.GENERALIZATION__CONTAINER);
		}
		return generalization;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Attribute> getAttribute() {
		if (attribute == null) {
			attribute = new EObjectContainmentEList<Attribute>(Attribute.class, this, UML_ERPackage.ENTITY__ATTRIBUTE);
		}
		return attribute;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isIsAbstract() {
		return isAbstract;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIsAbstract(boolean newIsAbstract) {
		boolean oldIsAbstract = isAbstract;
		isAbstract = newIsAbstract;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UML_ERPackage.ENTITY__IS_ABSTRACT, oldIsAbstract, isAbstract));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isIsWeak() {
		return isWeak;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIsWeak(boolean newIsWeak) {
		boolean oldIsWeak = isWeak;
		isWeak = newIsWeak;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UML_ERPackage.ENTITY__IS_WEAK, oldIsWeak, isWeak));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case UML_ERPackage.ENTITY__ATTRIBUTE:
				return ((InternalEList<?>)getAttribute()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case UML_ERPackage.ENTITY__GENERALIZATION:
				return getGeneralization();
			case UML_ERPackage.ENTITY__ATTRIBUTE:
				return getAttribute();
			case UML_ERPackage.ENTITY__IS_ABSTRACT:
				return isIsAbstract();
			case UML_ERPackage.ENTITY__IS_WEAK:
				return isIsWeak();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case UML_ERPackage.ENTITY__GENERALIZATION:
				getGeneralization().clear();
				getGeneralization().addAll((Collection<? extends Generalization>)newValue);
				return;
			case UML_ERPackage.ENTITY__ATTRIBUTE:
				getAttribute().clear();
				getAttribute().addAll((Collection<? extends Attribute>)newValue);
				return;
			case UML_ERPackage.ENTITY__IS_ABSTRACT:
				setIsAbstract((Boolean)newValue);
				return;
			case UML_ERPackage.ENTITY__IS_WEAK:
				setIsWeak((Boolean)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case UML_ERPackage.ENTITY__GENERALIZATION:
				getGeneralization().clear();
				return;
			case UML_ERPackage.ENTITY__ATTRIBUTE:
				getAttribute().clear();
				return;
			case UML_ERPackage.ENTITY__IS_ABSTRACT:
				setIsAbstract(IS_ABSTRACT_EDEFAULT);
				return;
			case UML_ERPackage.ENTITY__IS_WEAK:
				setIsWeak(IS_WEAK_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case UML_ERPackage.ENTITY__GENERALIZATION:
				return !getGeneralization().isEmpty();
			case UML_ERPackage.ENTITY__ATTRIBUTE:
				return attribute != null && !attribute.isEmpty();
			case UML_ERPackage.ENTITY__IS_ABSTRACT:
				return isAbstract != IS_ABSTRACT_EDEFAULT;
			case UML_ERPackage.ENTITY__IS_WEAK:
				return isWeak != IS_WEAK_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (isAbstract: ");
		result.append(isAbstract);
		result.append(", isWeak: ");
		result.append(isWeak);
		result.append(')');
		return result.toString();
	}

} //EntityImpl
